package com.j283_5.wisdom_park.controller.peree_management;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.j283_5.wisdom_park.common.result.ResultData;
import com.j283_5.wisdom_park.pojo.Person;
import com.j283_5.wisdom_park.pojo.Visitors;
import com.j283_5.wisdom_park.service.Peree_PersonService;

import com.j283_5.wisdom_park.vo.tenant_management.PersonVo;
import com.j283_5.wisdom_park.vo.tenant_management.Person_PereeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 租户信息管理
 * </p>
 *
 * @author 冯弋舟
 * @since 2022-04-28
 */
@RestController
@RequestMapping("/Peree_Person")
@Api(value = "租户人员管理",tags = "租户人员管理",produces="冯弋舟")
public class Peree_PersonController {

    @Resource
    private Peree_PersonService service;

    /**
     * 多条件查询人员信息
     * @return
     */
    @RequestMapping(value = "/findPeree_Person" , method = RequestMethod.GET)
    @ApiOperation(value = "多条件查询人员信息",notes = "多条件查询人员信息（分页）",produces="冯弋舟", response = ResultData.class)
    public ResultData findPeree_Person(@Param("page") Page<Visitors> page, @Param("personVo") PersonVo personVo){
        Map<String, Object> map = service.findPerson(personVo, (int) page.getCurrent(), (int) page.getSize());
        return ResultData.ok().data(map);
    }

    /**
     * 人员详情
     * @return
     */
    @RequestMapping(value = "/findPersonInfo" , method = RequestMethod.POST)
    @ApiOperation(value = "人员详情",notes = "人员详情",produces="冯弋舟", response = ResultData.class)
    public ResultData findPersonInfo(Integer person_id){
        List<Person> personInfo = service.findPersonInfo(person_id);
        List<Person_PereeVo> person_pereeVo = service.findPerson_PereeVo(person_id);
        Map<String,Object> map=new HashMap<>();
        map.put("personInfo",personInfo);
        map.put("person_pereeVo",person_pereeVo);
        return ResultData.ok().data(map);
    }

    /**
     * 人员新增
     * @return
     */
    @RequestMapping(value = "/InsertPersonInfo" , method = RequestMethod.POST)
    @ApiOperation(value = "人员新增",notes = "人员新增",produces="冯弋舟", response = ResultData.class)
    public ResultData InsertPersonInfo(Person_PereeVo personPereeVo){
       return service.insertPerson(personPereeVo);
    }
    /**
     * 人员删除
     * @return
     */
    @RequestMapping(value = "/DeletePersonInfo" , method = RequestMethod.POST)
    @ApiOperation(value = "人员删除",notes = "人员删除",produces="冯弋舟", response = ResultData.class)
    public ResultData DeletePersonInfo(@RequestBody List<Integer> ListPersonId){


        return service.deletePerson(ListPersonId);
    }

    /**
     * 进入人员新增界面时
     * @return
     */
    @RequestMapping(value = "/PersonInsertInterface" , method = RequestMethod.POST)
    @ApiOperation(value = "进入人员新增界面时",notes = "进入人员新增界面时",produces="冯弋舟", response = ResultData.class)
    public ResultData PersonInsertInterface(){

        return service.PersonInsertInterface();
    }
}
